﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpShare.Storage.Searching.Parameters {
    public class NameSearchParameter : SearchParameter {
        public NameSearchParameter(string text, bool fullMatch = false ) {
            this.Text = text;
            this.FullMatch = fullMatch;
        }

        public string Text { get; private set; }
        public bool FullMatch { get; private set; }

        public override bool Matches(IStorageItem item) {
            if (FullMatch) {
                return this.Text.Equals(item.Name, StringComparison.OrdinalIgnoreCase);
            }

            int index = item.Name.IndexOf(this.Text, StringComparison.OrdinalIgnoreCase);

            return (index > -1);
        }
    }
}
